package top.cluski.shardingsphere;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import top.cluski.shardingsphere.entity.Dict;
import top.cluski.shardingsphere.mapper.DictMapper;

import javax.annotation.Resource;

/**
 * 广播表测试
 */
@SpringBootTest
public class ShardingJDBCTestBroadcastTables {

    @Resource
    DictMapper dictMapper;

    @Test
    public void testDict() {
        Dict d = new Dict();
        d.setDictId((long) 1);
        d.setUstatus("1");
        d.setUvalue("正常");
        dictMapper.insert(d);

        Dict d2 = new Dict();
        d2.setDictId((long) 2);
        d2.setUstatus("0");
        d2.setUvalue("不正常");
        dictMapper.insert(d2);
    }

    @Test
    public void testDictSharding() {
        Dict d = new Dict();
//        d.setDictId((long) 1);
        d.setUstatus("1");
        d.setUvalue("正常");
        dictMapper.insert(d);

        Dict d2 = new Dict();
//        d2.setDictId((long) 2);
        d2.setUstatus("0");
        d2.setUvalue("不正常");
        dictMapper.insert(d2);
    }
}
